< previous page page_243 next page >

Page 243
Indexing the Information
When you put data into database tables, the individual records are usually stored in the order they were entered. This is called the physical order of the data. Unfortunately, you usually want to work with the data in an order different from the order in the database itself. For you to work with the data in the order you want, you need to define a logical order to the data. Also, you usually need to find specific records in a table quickly. Indexing the data in the tables provides you with a method of ordering the data.
An index is actually another database table that contains the key data for each record in the indexed table. The index itself is stored in a specific logic order maintained by the database. It also contains pointers that the database uses to find the actual record in the data table. Indexes are very similar to the index in the back of this book. To find a specific topic, you would look for it in the alphabetically listing and then, using the page number, go directly to that topic.
Because indexes are usually small tables that can be searched very quickly, they're used in all databases to provide quick access to the data and to display the data in a particular order. A table can have as many different indexes as needed; however, the more indexes a table has, the slower the database will perform when adding or deleting records from the table. This is because the database must update each index table for every change made to the actual table it references.
Another way of ordering your data is by using the ORDER BY clause of a SQL statement. This way, you can change the order of the data dynamically within your application.
Relationships..
After you normalize the tables and define the required indexes, you next need to define how the tables relate to one another. This operation is usually performed on paper and added to the database diagram, as shown in Figure 9.7.
12181-0243a.gif
Figure 9.7.
Database table relationships are usually defined in the database design
diagram.

 
< previous page page_243 next page >

If you like this book, buy it!